package f.f0.g;

import com.huawei.agconnect.exception.AGCServerException;
import f.a0;
import g.h;

/* compiled from: HttpHeaders */
public final class e {
    static {
        h.e("\"\\");
        h.e("\t ,=");
    }

    public static long a(a0 a0Var) {
        String c = a0Var.f.c("Content-Length");
        if (c != null) {
            try {
                return Long.parseLong(c);
            } catch (NumberFormatException unused) {
            }
        }
        return -1;
    }

    public static boolean b(a0 a0Var) {
        if (a0Var.a.b.equals("HEAD")) {
            return false;
        }
        int i = a0Var.c;
        if (((i >= 100 && i < AGCServerException.OK) || i == 204 || i == 304) && a(a0Var) == -1) {
            String c = a0Var.f.c("Transfer-Encoding");
            if (c == null) {
                c = null;
            }
            if ("chunked".equalsIgnoreCase(c)) {
                return true;
            }
            return false;
        }
        return true;
    }

    public static int c(String str, int i) {
        try {
            long parseLong = Long.parseLong(str);
            if (parseLong > 2147483647L) {
                return Integer.MAX_VALUE;
            }
            if (parseLong < 0) {
                return 0;
            }
            i = (int) parseLong;
            return i;
        } catch (NumberFormatException unused) {
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:218:0x0357  */
    /* JADX WARNING: Removed duplicated region for block: B:238:0x0362 A:{SYNTHETIC} */
    /* JADX WARNING: Missing exception handler attribute for start block: B:127:0x0211 */
    /* JADX WARNING: Missing block: B:43:0x00e2, code skipped:
            if (r20 <= 0) goto L_0x00f7;
     */
    /* JADX WARNING: Missing block: B:109:0x01c5, code skipped:
            if (r11 == null) goto L_0x0065;
     */
    /* JADX WARNING: Missing block: B:119:0x01f8, code skipped:
            if (r14 != null) goto L_0x0209;
     */
    /* JADX WARNING: Missing block: B:125:0x0207, code skipped:
            if (r14 == null) goto L_0x0230;
     */
    /* JADX WARNING: Missing block: B:126:0x0209, code skipped:
            java.lang.Thread.currentThread().interrupt();
     */
    /* JADX WARNING: Missing block: B:197:0x0311, code skipped:
            if (r0 != null) goto L_0x0322;
     */
    public static void d(f.j r34, f.r r35, f.q r36) {
        /*
        r1 = r34;
        r0 = r36;
        r2 = f.j.a;
        if (r1 != r2) goto L_0x0009;
    L_0x0008:
        return;
    L_0x0009:
        r2 = f.i.j;
        r2 = "Set-Cookie";
        r3 = r36.f();
        r5 = 0;
        r6 = 0;
        r7 = 0;
    L_0x0014:
        if (r6 >= r3) goto L_0x0032;
    L_0x0016:
        r8 = r0.d(r6);
        r8 = r2.equalsIgnoreCase(r8);
        if (r8 == 0) goto L_0x002f;
    L_0x0020:
        if (r7 != 0) goto L_0x0028;
    L_0x0022:
        r7 = new java.util.ArrayList;
        r8 = 2;
        r7.<init>(r8);
    L_0x0028:
        r8 = r0.g(r6);
        r7.add(r8);
    L_0x002f:
        r6 = r6 + 1;
        goto L_0x0014;
    L_0x0032:
        if (r7 == 0) goto L_0x0039;
    L_0x0034:
        r0 = java.util.Collections.unmodifiableList(r7);
        goto L_0x003d;
    L_0x0039:
        r0 = java.util.Collections.emptyList();
    L_0x003d:
        r2 = r0;
        r3 = r2.size();
        r6 = 0;
        r7 = 0;
    L_0x0044:
        if (r6 >= r3) goto L_0x0369;
    L_0x0046:
        r0 = r2.get(r6);
        r8 = r0;
        r8 = (java.lang.String) r8;
        r9 = java.lang.System.currentTimeMillis();
        r11 = r8.length();
        r12 = 59;
        r0 = f.f0.c.j(r8, r5, r11, r12);
        r13 = 61;
        r14 = f.f0.c.j(r8, r5, r0, r13);
        if (r14 != r0) goto L_0x006a;
    L_0x0063:
        r8 = r35;
    L_0x0065:
        r27 = r2;
    L_0x0067:
        r4 = 0;
        goto L_0x0353;
    L_0x006a:
        r16 = f.f0.c.z(r8, r5, r14);
        r15 = r16.isEmpty();
        if (r15 != 0) goto L_0x0063;
    L_0x0074:
        r15 = f.f0.c.r(r16);
        r4 = -1;
        if (r15 == r4) goto L_0x007c;
    L_0x007b:
        goto L_0x0063;
    L_0x007c:
        r14 = r14 + 1;
        r17 = f.f0.c.z(r8, r14, r0);
        r14 = f.f0.c.r(r17);
        if (r14 == r4) goto L_0x0089;
    L_0x0088:
        goto L_0x0063;
    L_0x0089:
        r0 = r0 + 1;
        r18 = -1;
        r4 = 1;
        r20 = r18;
        r22 = 0;
        r23 = 0;
        r24 = 1;
        r25 = 0;
        r26 = 253402300799999; // 0xe677d21fdbff float:-1.71647681E11 double:1.251973714024093E-309;
        r28 = 0;
        r29 = 0;
    L_0x00a1:
        r30 = 9223372036854775807; // 0x7fffffffffffffff float:NaN double:NaN;
        r32 = -9223372036854775808;
        if (r0 >= r11) goto L_0x0157;
    L_0x00aa:
        r14 = f.f0.c.j(r8, r0, r11, r12);
        r15 = f.f0.c.j(r8, r0, r14, r13);
        r0 = f.f0.c.z(r8, r0, r15);
        if (r15 >= r14) goto L_0x00bf;
    L_0x00b8:
        r15 = r15 + 1;
        r15 = f.f0.c.z(r8, r15, r14);
        goto L_0x00c1;
    L_0x00bf:
        r15 = "";
    L_0x00c1:
        r12 = "expires";
        r12 = r0.equalsIgnoreCase(r12);
        if (r12 == 0) goto L_0x00d2;
    L_0x00c9:
        r0 = r15.length();	 Catch:{ IllegalArgumentException -> 0x0151 }
        r26 = f.i.b(r15, r5, r0);	 Catch:{ IllegalArgumentException -> 0x0151 }
        goto L_0x00fc;
    L_0x00d2:
        r12 = "max-age";
        r12 = r0.equalsIgnoreCase(r12);
        if (r12 == 0) goto L_0x0100;
    L_0x00da:
        r20 = java.lang.Long.parseLong(r15);	 Catch:{ NumberFormatException -> 0x00e5 }
        r30 = 0;
        r0 = (r20 > r30 ? 1 : (r20 == r30 ? 0 : -1));
        if (r0 > 0) goto L_0x00fc;
    L_0x00e4:
        goto L_0x00f7;
    L_0x00e5:
        r0 = move-exception;
        r12 = r0;
        r0 = "-?\\d+";
        r0 = r15.matches(r0);	 Catch:{  }
        if (r0 == 0) goto L_0x00ff;
    L_0x00ef:
        r0 = "-";
        r0 = r15.startsWith(r0);	 Catch:{  }
        if (r0 == 0) goto L_0x00fa;
    L_0x00f7:
        r20 = r32;
        goto L_0x00fc;
    L_0x00fa:
        r20 = r30;
    L_0x00fc:
        r25 = 1;
        goto L_0x0151;
    L_0x00ff:
        throw r12;	 Catch:{  }
    L_0x0100:
        r12 = "domain";
        r12 = r0.equalsIgnoreCase(r12);
        if (r12 == 0) goto L_0x0131;
    L_0x0108:
        r0 = ".";
        r12 = r15.endsWith(r0);	 Catch:{ IllegalArgumentException -> 0x0151 }
        if (r12 != 0) goto L_0x012b;
    L_0x0110:
        r0 = r15.startsWith(r0);	 Catch:{ IllegalArgumentException -> 0x0151 }
        if (r0 == 0) goto L_0x011a;
    L_0x0116:
        r15 = r15.substring(r4);	 Catch:{ IllegalArgumentException -> 0x0151 }
    L_0x011a:
        r0 = f.f0.c.c(r15);	 Catch:{ IllegalArgumentException -> 0x0151 }
        if (r0 == 0) goto L_0x0125;
    L_0x0120:
        r28 = r0;
        r24 = 0;
        goto L_0x0151;
    L_0x0125:
        r0 = new java.lang.IllegalArgumentException;	 Catch:{ IllegalArgumentException -> 0x0151 }
        r0.<init>();	 Catch:{ IllegalArgumentException -> 0x0151 }
        throw r0;	 Catch:{ IllegalArgumentException -> 0x0151 }
    L_0x012b:
        r0 = new java.lang.IllegalArgumentException;	 Catch:{ IllegalArgumentException -> 0x0151 }
        r0.<init>();	 Catch:{ IllegalArgumentException -> 0x0151 }
        throw r0;	 Catch:{ IllegalArgumentException -> 0x0151 }
    L_0x0131:
        r12 = "path";
        r12 = r0.equalsIgnoreCase(r12);
        if (r12 == 0) goto L_0x013c;
    L_0x0139:
        r29 = r15;
        goto L_0x0151;
    L_0x013c:
        r12 = "secure";
        r12 = r0.equalsIgnoreCase(r12);
        if (r12 == 0) goto L_0x0147;
    L_0x0144:
        r22 = 1;
        goto L_0x0151;
    L_0x0147:
        r12 = "httponly";
        r0 = r0.equalsIgnoreCase(r12);
        if (r0 == 0) goto L_0x0151;
    L_0x014f:
        r23 = 1;
    L_0x0151:
        r0 = r14 + 1;
        r12 = 59;
        goto L_0x00a1;
    L_0x0157:
        r0 = (r20 > r32 ? 1 : (r20 == r32 ? 0 : -1));
        if (r0 != 0) goto L_0x0160;
    L_0x015b:
        r8 = r35;
        r18 = r32;
        goto L_0x018f;
    L_0x0160:
        r0 = (r20 > r18 ? 1 : (r20 == r18 ? 0 : -1));
        if (r0 == 0) goto L_0x018b;
    L_0x0164:
        r11 = 9223372036854775; // 0x20c49ba5e353f7 float:-3.943512E-16 double:4.663754807431093E-308;
        r0 = (r20 > r11 ? 1 : (r20 == r11 ? 0 : -1));
        if (r0 > 0) goto L_0x0171;
    L_0x016d:
        r11 = 1000; // 0x3e8 float:1.401E-42 double:4.94E-321;
        r30 = r20 * r11;
    L_0x0171:
        r30 = r9 + r30;
        r0 = (r30 > r9 ? 1 : (r30 == r9 ? 0 : -1));
        r8 = 253402300799999; // 0xe677d21fdbff float:-1.71647681E11 double:1.251973714024093E-309;
        if (r0 < 0) goto L_0x0186;
    L_0x017c:
        r0 = (r30 > r8 ? 1 : (r30 == r8 ? 0 : -1));
        if (r0 <= 0) goto L_0x0181;
    L_0x0180:
        goto L_0x0186;
    L_0x0181:
        r8 = r35;
        r18 = r30;
        goto L_0x018f;
    L_0x0186:
        r18 = r8;
        r8 = r35;
        goto L_0x018f;
    L_0x018b:
        r8 = r35;
        r18 = r26;
    L_0x018f:
        r0 = r8.d;
        r9 = 46;
        r10 = r28;
        if (r10 != 0) goto L_0x0199;
    L_0x0197:
        r10 = r0;
        goto L_0x01c9;
    L_0x0199:
        r11 = r0.equals(r10);
        if (r11 == 0) goto L_0x01a0;
    L_0x019f:
        goto L_0x01c2;
    L_0x01a0:
        r11 = r0.endsWith(r10);
        if (r11 == 0) goto L_0x01c4;
    L_0x01a6:
        r11 = r0.length();
        r12 = r10.length();
        r11 = r11 - r12;
        r11 = r11 - r4;
        r11 = r0.charAt(r11);
        if (r11 != r9) goto L_0x01c4;
    L_0x01b6:
        r11 = f.f0.c.r;
        r11 = r11.matcher(r0);
        r11 = r11.matches();
        if (r11 != 0) goto L_0x01c4;
    L_0x01c2:
        r11 = 1;
        goto L_0x01c5;
    L_0x01c4:
        r11 = 0;
    L_0x01c5:
        if (r11 != 0) goto L_0x01c9;
    L_0x01c7:
        goto L_0x0065;
    L_0x01c9:
        r0 = r0.length();
        r11 = r10.length();
        if (r0 == r11) goto L_0x0320;
    L_0x01d3:
        r11 = okhttp3.internal.publicsuffix.PublicSuffixDatabase.h;
        java.util.Objects.requireNonNull(r11);
        r0 = java.net.IDN.toUnicode(r10);
        r12 = "\\.";
        r12 = r0.split(r12);
        r13 = okhttp3.internal.publicsuffix.PublicSuffixDatabase.f;
        r0 = r11.a;
        r0 = r0.get();
        if (r0 != 0) goto L_0x0223;
    L_0x01ec:
        r0 = r11.a;
        r0 = r0.compareAndSet(r5, r4);
        if (r0 == 0) goto L_0x0223;
    L_0x01f4:
        r14 = 0;
    L_0x01f5:
        r11.b();	 Catch:{ InterruptedIOException -> 0x0211, IOException -> 0x01fd }
        if (r14 == 0) goto L_0x0230;
    L_0x01fa:
        goto L_0x0209;
    L_0x01fb:
        r0 = move-exception;
        goto L_0x0219;
    L_0x01fd:
        r0 = move-exception;
        r15 = r0;
        r0 = f.f0.j.f.a;	 Catch:{ all -> 0x01fb }
        r9 = 5;
        r5 = "Failed to read public suffix list";
        r0.l(r9, r5, r15);	 Catch:{ all -> 0x01fb }
        if (r14 == 0) goto L_0x0230;
    L_0x0209:
        r0 = java.lang.Thread.currentThread();
        r0.interrupt();
        goto L_0x0230;
    L_0x0211:
        java.lang.Thread.interrupted();	 Catch:{ all -> 0x01fb }
        r5 = 0;
        r9 = 46;
        r14 = 1;
        goto L_0x01f5;
    L_0x0219:
        if (r14 == 0) goto L_0x0222;
    L_0x021b:
        r1 = java.lang.Thread.currentThread();
        r1.interrupt();
    L_0x0222:
        throw r0;
    L_0x0223:
        r0 = r11.b;	 Catch:{ InterruptedException -> 0x0229 }
        r0.await();	 Catch:{ InterruptedException -> 0x0229 }
        goto L_0x0230;
    L_0x0229:
        r0 = java.lang.Thread.currentThread();
        r0.interrupt();
    L_0x0230:
        monitor-enter(r11);
        r0 = r11.c;	 Catch:{ all -> 0x031d }
        if (r0 == 0) goto L_0x0315;
    L_0x0235:
        monitor-exit(r11);	 Catch:{ all -> 0x031d }
        r0 = r12.length;
        r5 = new byte[r0][];
        r9 = 0;
    L_0x023a:
        r14 = r12.length;
        if (r9 >= r14) goto L_0x024a;
    L_0x023d:
        r14 = r12[r9];
        r15 = f.f0.c.j;
        r14 = r14.getBytes(r15);
        r5[r9] = r14;
        r9 = r9 + 1;
        goto L_0x023a;
    L_0x024a:
        r9 = 0;
    L_0x024b:
        if (r9 >= r0) goto L_0x0259;
    L_0x024d:
        r14 = r11.c;
        r14 = okhttp3.internal.publicsuffix.PublicSuffixDatabase.a(r14, r5, r9);
        if (r14 == 0) goto L_0x0256;
    L_0x0255:
        goto L_0x025a;
    L_0x0256:
        r9 = r9 + 1;
        goto L_0x024b;
    L_0x0259:
        r14 = 0;
    L_0x025a:
        if (r0 <= r4) goto L_0x0279;
    L_0x025c:
        r9 = r5.clone();
        r9 = (byte[][]) r9;
        r27 = r2;
        r15 = 0;
    L_0x0265:
        r2 = r9.length;
        r2 = r2 - r4;
        if (r15 >= r2) goto L_0x027b;
    L_0x0269:
        r2 = okhttp3.internal.publicsuffix.PublicSuffixDatabase.e;
        r9[r15] = r2;
        r2 = r11.c;
        r2 = okhttp3.internal.publicsuffix.PublicSuffixDatabase.a(r2, r9, r15);
        if (r2 == 0) goto L_0x0276;
    L_0x0275:
        goto L_0x027c;
    L_0x0276:
        r15 = r15 + 1;
        goto L_0x0265;
    L_0x0279:
        r27 = r2;
    L_0x027b:
        r2 = 0;
    L_0x027c:
        if (r2 == 0) goto L_0x028f;
    L_0x027e:
        r9 = 0;
    L_0x027f:
        r15 = r0 + -1;
        if (r9 >= r15) goto L_0x028f;
    L_0x0283:
        r15 = r11.d;
        r15 = okhttp3.internal.publicsuffix.PublicSuffixDatabase.a(r15, r5, r9);
        if (r15 == 0) goto L_0x028c;
    L_0x028b:
        goto L_0x0290;
    L_0x028c:
        r9 = r9 + 1;
        goto L_0x027f;
    L_0x028f:
        r15 = 0;
    L_0x0290:
        if (r15 == 0) goto L_0x02aa;
    L_0x0292:
        r0 = new java.lang.StringBuilder;
        r0.<init>();
        r2 = "!";
        r0.append(r2);
        r0.append(r15);
        r0 = r0.toString();
        r2 = "\\.";
        r0 = r0.split(r2);
        goto L_0x02c9;
    L_0x02aa:
        if (r14 != 0) goto L_0x02b1;
    L_0x02ac:
        if (r2 != 0) goto L_0x02b1;
    L_0x02ae:
        r0 = okhttp3.internal.publicsuffix.PublicSuffixDatabase.g;
        goto L_0x02c9;
    L_0x02b1:
        if (r14 == 0) goto L_0x02ba;
    L_0x02b3:
        r0 = "\\.";
        r0 = r14.split(r0);
        goto L_0x02bb;
    L_0x02ba:
        r0 = r13;
    L_0x02bb:
        if (r2 == 0) goto L_0x02c3;
    L_0x02bd:
        r5 = "\\.";
        r13 = r2.split(r5);
    L_0x02c3:
        r2 = r0.length;
        r5 = r13.length;
        if (r2 <= r5) goto L_0x02c8;
    L_0x02c7:
        goto L_0x02c9;
    L_0x02c8:
        r0 = r13;
    L_0x02c9:
        r2 = r12.length;
        r5 = r0.length;
        r9 = 33;
        if (r2 != r5) goto L_0x02da;
    L_0x02cf:
        r2 = 0;
        r5 = r0[r2];
        r5 = r5.charAt(r2);
        if (r5 == r9) goto L_0x02db;
    L_0x02d8:
        r0 = 0;
        goto L_0x0311;
    L_0x02da:
        r2 = 0;
    L_0x02db:
        r5 = r0[r2];
        r5 = r5.charAt(r2);
        if (r5 != r9) goto L_0x02e6;
    L_0x02e3:
        r2 = r12.length;
        r0 = r0.length;
        goto L_0x02e9;
    L_0x02e6:
        r2 = r12.length;
        r0 = r0.length;
        r0 = r0 + r4;
    L_0x02e9:
        r2 = r2 - r0;
        r0 = new java.lang.StringBuilder;
        r0.<init>();
        r5 = "\\.";
        r5 = r10.split(r5);
    L_0x02f5:
        r9 = r5.length;
        if (r2 >= r9) goto L_0x0305;
    L_0x02f8:
        r9 = r5[r2];
        r0.append(r9);
        r9 = 46;
        r0.append(r9);
        r2 = r2 + 1;
        goto L_0x02f5;
    L_0x0305:
        r2 = r0.length();
        r2 = r2 - r4;
        r0.deleteCharAt(r2);
        r0 = r0.toString();
    L_0x0311:
        if (r0 != 0) goto L_0x0322;
    L_0x0313:
        goto L_0x0067;
    L_0x0315:
        r0 = new java.lang.IllegalStateException;	 Catch:{ all -> 0x031d }
        r1 = "Unable to load publicsuffixes.gz resource from the classpath.";
        r0.<init>(r1);	 Catch:{ all -> 0x031d }
        throw r0;	 Catch:{ all -> 0x031d }
    L_0x031d:
        r0 = move-exception;
        monitor-exit(r11);	 Catch:{ all -> 0x031d }
        throw r0;
    L_0x0320:
        r27 = r2;
    L_0x0322:
        r2 = r29;
        if (r2 == 0) goto L_0x0333;
    L_0x0326:
        r0 = "/";
        r0 = r2.startsWith(r0);
        if (r0 != 0) goto L_0x032f;
    L_0x032e:
        goto L_0x0333;
    L_0x032f:
        r21 = r2;
        r4 = 0;
        goto L_0x034a;
    L_0x0333:
        r0 = r35.f();
        r2 = 47;
        r2 = r0.lastIndexOf(r2);
        if (r2 == 0) goto L_0x0345;
    L_0x033f:
        r4 = 0;
        r0 = r0.substring(r4, r2);
        goto L_0x0348;
    L_0x0345:
        r4 = 0;
        r0 = "/";
    L_0x0348:
        r21 = r0;
    L_0x034a:
        r0 = new f.i;
        r15 = r0;
        r20 = r10;
        r15.m4783init(r16, r17, r18, r20, r21, r22, r23, r24, r25);
        goto L_0x0354;
    L_0x0353:
        r0 = 0;
    L_0x0354:
        if (r0 != 0) goto L_0x0357;
    L_0x0356:
        goto L_0x0362;
    L_0x0357:
        if (r7 != 0) goto L_0x035f;
    L_0x0359:
        r2 = new java.util.ArrayList;
        r2.<init>();
        r7 = r2;
    L_0x035f:
        r7.add(r0);
    L_0x0362:
        r6 = r6 + 1;
        r2 = r27;
        r5 = 0;
        goto L_0x0044;
    L_0x0369:
        if (r7 == 0) goto L_0x0370;
    L_0x036b:
        r0 = java.util.Collections.unmodifiableList(r7);
        goto L_0x0374;
    L_0x0370:
        r0 = java.util.Collections.emptyList();
    L_0x0374:
        r0 = r0.isEmpty();
        if (r0 == 0) goto L_0x037b;
    L_0x037a:
        return;
    L_0x037b:
        r0 = r1;
        r0 = (f.j.a) r0;
        java.util.Objects.requireNonNull(r0);
        return;
        */
        throw new UnsupportedOperationException("Method not decompiled: f.f0.g.e.d(f.j, f.r, f.q):void");
    }

    public static int e(String str, int i, String str2) {
        while (i < str.length() && str2.indexOf(str.charAt(i)) == -1) {
            i++;
        }
        return i;
    }
}
